Skip to content

Expose classes_/predict_proba on calibrated classifiers for global explainers - #813

Closed
Creylay wants to merge 1 commit into
developfrom
fix/global-explainer-linear-svc-sgd
Closed

Expose classes_/predict_proba on calibrated classifiers for global explainers#813
Creylay wants to merge 1 commit into
developfrom
fix/global-explainer-linear-svc-sgd

Conversation

@Creylay

@Creylay Creylay commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

LinearSVCClassifier and SGDClassifier calibrate probabilities via an internal CalibratedClassifierCV (self._calibrated) instead of fitting themselves, so they never exposed classes_ or predict_proba on the wrapper instance. sklearn's inspection utilities (permutation_importance, partial_dependence) read estimator.classes_ unconditionally on any object tagged as a classifier, so running a global explainer (Permutation Feature Importance, Partial Dependence) on either model crashed with AttributeError: '...Classifier' object has no attribute 'classes_'. Local explainers were unaffected since they call model.predict() directly, bypassing that machinery.

Fix proxies classes_ and predict_proba from the internal calibrated model onto self, so both models now work correctly with all explainers instead of just being blocked from using them.


Type of Change

Check all that apply like this [x]:

  • Backend change
  • Frontend change
  • CI / Workflow change
  • Build / Packaging change
  • Bug fix
  • Documentation

Changes (by file)

  • DashAI/back/models/scikit_learn/linear_svc_classifier.py: added classes_ property and predict_proba method that delegate to the internal CalibratedClassifierCV.
  • DashAI/back/models/scikit_learn/sgd_classifier.py: same fix, same root cause.
  • tests/back/explainers/test_explainers.py: added regression tests running Permutation Feature Importance and Partial Dependence against both calibrated classifiers.

Testing (optional)

To verify manually:

  1. Train a Linear SVC or SGD Classifier model on any tabular classification dataset.
  2. Go to Explainability → add a global explainer (Permutation Feature Importance or Partial Dependence) and run it.
  3. Before this fix, it would fail with AttributeError: '...Classifier' object has no attribute 'classes_'. It should now complete successfully.

@Creylay Creylay added bug Something isn't working back Backend work labels Aug 12, 2026
@cristian-tamblay

Copy link
Copy Markdown
Member

This was already fixed by #812 . Closing this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

back Backend work bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants